package cn.tedu.spring.life;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class Life {
    private String meaning;

    public Life() {
        System.out.println("1:通过无参构造实例化");
    }

    @Value("这个世界不仅属于我，还属于我的动物朋友们")
    public void setMeaning(String meaning) {
        this.meaning = meaning;
        System.out.println("2:通过set方法属性赋值");
    }
    //3.初始化
    @PostConstruct
    public void init() {
        System.out.println("3:声明周期初始化方法");
    }

    //5.销毁之前
    @PreDestroy
    public void destroy(){
        System.out.println("5:生命周期销毁方法");
    }
}
